package com.snbc.TestDemo;

import java.util.Arrays;

/**
 * @Classname BubbleSort
 * @Description TODO
 * @Date 2019/9/17 22:58
 * @Created by Acer
 */
public class BubbleSort {
    public int[] bubbleSort(int[] array) {
        int temp;
        for (int i = 0; i < array.length; i++) {
            for (int j = i + 1; j < array.length; j++) {
                if (array[i] > array[j]) {
                    temp = array[j];
                    array[j] = array[i];
                    array[i] = temp;
                }
            }

        }
        return array;
    }

    public static void main(String[] args) {
        BubbleSort bubbleSort = new BubbleSort();
        int[] ar = bubbleSort.bubbleSort(new int[]{10, 9, 10, 23, 1});
        System.out.println(Arrays.toString(ar));
    }
}
